home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 7031 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.0 KB

  1. Path: osf1.gmu.edu!adomingu
  2. From: adomingu@osf1.gmu.edu (Aires C Domingues)
  3. Newsgroups: comp.lang.c
  4. Subject: "Double to 2 Unsigned Longs"
  5. Date: 17 Feb 1996 17:36:21 GMT
  6. Organization: George Mason University, Fairfax, Virginia, USA
  7. Message-ID: <4g53ml$haj@portal.gmu.edu>
  8. NNTP-Posting-Host: osf1.gmu.edu
  9. Mime-Version: 1.0
  10. Content-Type: text/plain; charset=US-ASCII
  11. Content-Transfer-Encoding: 7bit
  12. X-Newsreader: TIN [version 1.2 PL2]
  13.  
  14. How to go about storing a double (used to store very large integers) to
  15. a user defined 64 bit integer (structure with two unsigned long fields)?
  16.  
  17. The user defined 64 bit integer looks something like this:
  18.  
  19. typedef struct {
  20.   unsigned long high;
  21.   unsigned long low;
  22. } UINT64;
  23.  
  24. Where "high" is used to save the high order bits for the really big integer,
  25. and "low" is used for the low order bits.
  26.  
  27. One idea is to take the double and divide it by 2**32.  The we can save the
  28. resulting integral part of the division in "high", and the remainder in the
  29. "low".  This will off-course lead to rounding errors.  Any other ideas?
  30.